<!--suppress ALL -->
<include file="./Template/header.html" />
<link rel="stylesheet" type="text/css" href="/Template/css/messagebox.css">
<script type="text/javascript">

    $(function() {

        //初始化页面配置
        initPage("保修卡注册");

        var app = new Vue({
            el: '#container',
            data: {
                info: [],
            },
            methods: {

                index: indexPage,
                cancel: function() {
                    window.location.href = "/wechat";
                },
                save: function() {

                    var guaranteeId = $("input[name=guaranteeId]").val();
                    var customerId = $("input[name=customerId]").val();
                    var invoiceNumber = $("input[name=invoiceNumber]").val();
                    var invoiceName = $("input[name=invoiceName]").val();
//                    var number = $("input[name=number]").val();
                    var productName = $("input[name=productName]").val();
                    var note = $("textarea[name=note]").val();

                    if(isNullOrEmpty(invoiceNumber)) {
                        alert("请填写发票号");
                        return false;
                    }

                    if(isNullOrEmpty(invoiceName)) {
                        alert("请填写购买方名称");
                        return false;
                    }
//                    if(!checkPhone(number)) {
//                        alert("联系电话位数不对");
//                        return false;
//                    }

                    $.ajax({
                        url:"/wechat/clubfoot/updateGuarantee",
                        type:"post",
                        data:{
                            guaranteeId: guaranteeId,
                            customerId: customerId,
                            invoiceNumber: invoiceNumber,
                            invoiceName: invoiceName,
                            note: note,
                        },

                        dataType:"JSON",
                        beforeSend:function(){
                            $("#loadingToast").show();
                        },
                        complete:function(){
                            $('#loadingToast').hide();
                        },
                        success:function(data){
                            if(data.code == 200) {
                                alert("提交成功");
                                window.location.href = "/wechat/clubfoot/checkin";
                            }
                        },
                    })

                }

            }
        })


        $("input[type=date]").change(function() {
            var value = $(this).val();
            $(this).prev().val(value);
        });

    });


</script>
<div class="hint-info">
    请根据保修卡说明填写保修注册。
</div>
<div class="edit-content">
    <input type="text" style="display: none;" name="guaranteeId" value="{$info.guarantee_id}">
    <input type="text" style="display: none;" name="customerId" value="{$customerId}">
    <div class="item">
        <span>发票号*</span>
        <input type="text" name="invoiceNumber" value="{$info.invoice_number}" placeholder="请填写发票上的发票号码">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <div class="item">
        <span>购买人*</span>
        <input type="text" name="invoiceName" value="{$info.invoice_name}" placeholder="请填写发票上的购买方名称">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div>
    <!--div class="item">
        <span>联系电话</span>
        <input type="text" name="number" value="{$info.number}" placeholder="请填写您的电话号码">
        <img class="icon-right" src="/Template/images/icon-right.png" alt="">
    </div-->
    <div class="title-span">
        <span>留言</span>
    </div>
    <div class="area">
        <textarea class="t-area" name="note" placeholder="请填写您的留言（非必填）">{$info.note}</textarea>
    </div>
</div>
<if condition="$info[guarantee_id] gt 0" >
    <div class="operation-btn">
        <div class="cancel-btn" v-on:click="cancel">返回</div>
    </div>
    <else/>
    <div class="operation-btn">
        <div class="cancel-btn" v-on:click="cancel">取消</div>
        <div class="save-btn" v-on:click="save">提交</div>
    </div>
</if>

<include file="./Template/footer.html" />

